﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<!doctype html>
<html lang="en" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml">
<head runat="server">
    <meta charset="utf-8">
    <meta property="fb:app_id" content="<%= ViewData["ApplicationId"] %>" />
    <meta property="og:title" content="ShareThrift">
    <meta property="og:url" content="<% = HttpContext.Current.Request.Url.AbsoluteUri %>">
    <meta property="og:image" content="http://photos-e.ak.fbcdn.net/photos-ak-snc1/v27562/57/123419921037393/app_1_123419921037393_6959.gif">
    <meta property="og:site_name" content="ShareThrift">
    <meta property="og:description" content="A Demo site for the Open Source FaceSharp library.">
    <meta property="og:type" content="website">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <title>Index</title>

    <meta property="fb:app_id" content="<%= ViewData["ApplicationId"] %>" />
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
    <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
    <script>!window.jQuery && document.write(unescape('%3Cscript src="/scripts/jquery-1.5.min.js"%3E%3C/script%3E'))</script>
</head>
<body>
 <script type="text/javascript">
     //top.location.href = 'http://www.facebook.com/apps/application.php?id=123419921037393&sk=app_123419921037393';
     //window.open('http://www.facebook.com/apps/application.php?id=123419921037393&sk=app_123419921037393', '_parent');
</script>
<script src="http://connect.facebook.net/en_US/all.js"></script>
     <script>
         window.fbAsyncInit = function () {
             FB.init({ appId: '<%= ViewData["ApplicationId"] %>', status: true, cookie: true, xfbml: true });
         };


         function shareIt() {
             FB.ui(
               {
                   method: 'feed',
                   name: 'FaceSharp Facebook .NET SDK and Starter Kit',
                   link: 'http://www.facesharp.com',
                   picture: 'http://<%=HttpContext.Current.Request.Url.Host %>/Areas/FacebookApp/Images/logo-facesharp.gif',
                   caption: 'Completely open source, community supported and developed.',
                   description: 'FaceSharp makes it easy to develop Facebook apps quickly.',
                   properties: {'hey ':{ 'text': 'Visit our Website', 'href': 'http://www.facesharp.com/' }, 'example 1': 'this can be text', ' ': 'example 2 .. this can be text or a link with no leading copy', 'example 3': 'more text','example 4': 'final text'},
                   actions: [
                    { name: 'Twitter', link: 'http://twitter.com/facesharp' }
                   ]

               },
               function (response) {
                   if (response && response.post_id) {
                       alert('Post was published.');
                   } else {
                       alert('Post was not published.');
                   }
               }
             );
         }

         function askForMorePermissions() {

             FB.login(function (response) {
                 if (response.session) {
                     if (response.perms) {
                         // user is logged in and granted some permissions.
                         // perms is a comma separated list of granted permissions
                     } else {
                         // user is logged in, but did not grant any permissions
                     }
                 } else {
                     // user is not logged in
                 }
             }, { perms: 'rsvp_event,create_event' });


         }

         function getCountOfFriendsInCommon(uid) {
             return 1;
         }

         function closestFriends() {

             FB.api(
                    {
                        method: 'fql.query',
                        query: '' +
                        'SELECT uid, name FROM user WHERE uid IN ' +
                        '( ' +
                        'SELECT fromid FROM comment WHERE ' +
                        'object_id IN (SELECT post_id FROM stream WHERE source_id = me()) OR ' +
                        'object_id IN (SELECT status_id FROM status WHERE uid = me()) OR ' +
                        'object_id IN (SELECT object_id FROM album WHERE owner =  me()) OR ' +
                        'object_id IN (SELECT object_id FROM photo WHERE aid in (SELECT aid FROM album WHERE owner =  me())) OR ' +
                        'object_id IN (SELECT vid FROM video WHERE owner =  me()) OR ' +
                        'object_id IN (SELECT note_id FROM note WHERE uid =  me()) OR ' +
                        'object_id IN (SELECT link_id FROM link WHERE owner =  me()) ' +
                        ') ' +
                        'OR uid IN ' +
                        '( ' +
                        'SELECT user_id FROM like WHERE  ' +
                        'object_id IN (SELECT post_id FROM stream WHERE source_id = me()) OR ' +
                        'object_id IN (SELECT status_id FROM status WHERE uid = me()) OR ' +
                        'object_id IN (SELECT object_id FROM album WHERE owner =  me()) OR ' +
                        'object_id IN (SELECT object_id FROM photo WHERE aid in (SELECT aid FROM album WHERE owner =  me())) OR ' +
                        'object_id IN (SELECT vid FROM video WHERE owner =  me()) OR ' +
                        'object_id IN (SELECT note_id FROM note WHERE uid =  me()) OR ' +
                        'object_id IN (SELECT link_id FROM link WHERE owner =  me()) ' +
                        ') ' +
                        'OR uid IN ' +
                        '( ' +
                        'SELECT subject FROM photo_tag WHERE pid IN ( ' +
                        '   SELECT pid FROM photo WHERE aid in (SELECT aid FROM album WHERE owner =  me()) ' +
                        ' ) ' +
                        ') ' +
                        'OR uid IN ' +
                        '( ' +
                        ' SELECT subject FROM video_tag WHERE vid IN ( ' +
                        '   SELECT vid FROM video WHERE owner =  me() ' +
                        ' ) ' +
                        ') '

                    },
                    function (response) {
                        console.log(response);
                        $.each(response, function (i, data) {

                            console.log(data);
                        });

                        //alert('Name is ' + response[0].name);
                    }
                );

         }

     </script>


    <div id="fb-root"></div>

     This is a test of a Facebook enabled website.<br />
     <br />
     This page showcases the ability to prompt the user to authenticate an app either by logging in or by interacting in a way that requires login first.<br />
     <br />

     

     <hr noshade />
     <h3>Facebook Sharing:</h3>
     Facebook share button is still supported, but will likely go away.<br />

      <b>Javascript Share Button:</b> <br /><br />
      

      (Box count)<br />
      <divstyle="clear:both">
      <a name="fb_share" type="box_count" share_url="<% =HttpContext.Current.Request.Url.AbsoluteUri %>"></a>
      </div>
      
      <div style="clear:both">
      <br /><br />
      (Button count)<br />
      <a name="fb_share" type="button_count" share_url="<% =HttpContext.Current.Request.Url.AbsoluteUri %>"></a>
      </div>
      <br /><br />
      (Button)<br />
      <a name="fb_share" type="button" share_url="<% =HttpContext.Current.Request.Url.AbsoluteUri %>"></a><br /><br />

      (Icon Link)<br />
      <a name="fb_share" type="icon_link" share_url="<% =HttpContext.Current.Request.Url.AbsoluteUri %>"></a><br /><br />

       (Icon)<br />
      <a name="fb_share" type="icon" share_url="<% =HttpContext.Current.Request.Url.AbsoluteUri %>"></a><br /><br />

      <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>

     <b>XFBML Share Button:</b> <br /><br />
     
     (using on page meta tags)<br />
     <fb:share-button class="url" href="<% =HttpContext.Current.Request.Url.AbsoluteUri %>" ></fb:share-button>
     <br /><br />

     (using in-line meta tags)<br />
     <fb:share-button class="meta" >
      <meta name="medium" content="promo" /> 
            <meta name="title" content="WHAT MAKES YOU A COVERGIRL?" /> 
            <meta name="description" content="We want to know! Join My COVERGIRL for a chance to win free makeup and once-in-a-lifetime experiences with Ellen, Taylor, Queen or Drew. Plus, a chance to star in your own @COVERGIRL video!" /> 
            <link rel="image_src" href="http://<%=HttpContext.Current.Request.Url.Host %>/Areas/FacebookApp/Images/logo-facesharp.gif" /> 
            <link rel="target_url" href="<%= HttpContext.Current.Request.Url.AbsoluteUri %>" />  
     </fb:share-button>
     <br /><br />

     <b>Hyperlink to Share URL:</b> <br />
     <a href="http://www.facebook.com/sharer/sharer.php?u=<%= Server.UrlEncode(HttpContext.Current.Request.Url.AbsoluteUri) %>" target="_blank">Share This</a>
     <br /><br />

     <b>Javascript Share:</b><br />
    <input type="button" value="Share with Facebook" onclick="shareIt();"/>
    <br /><br />






     <hr noshade />
     <h3>Facebook Login Button:</h3>
     <a href="http://developers.facebook.com/docs/reference/plugins/login/">Facebook Documentation - Social Plugins - Login Button</a>
     <br /><br />
     <% if (ViewData["user"] != null)
        { %>
        <fb:login-button autologoutlink="true" perms="<%= ViewData["ExtendedPermissions"] %>" onlogin="window.location.reload();">Log out - [Customizable Button Text]</fb:login-button>
     
     <% } else {%>
     <fb:login-button autologoutlink="true" perms="<%= ViewData["ExtendedPermissions"] %>" onlogin="window.location.reload();">Login with Facebook - [Customizable Button Text]</fb:login-button>
     
     <% } %>
     <br /><br />
     

         <% if (ViewData["user"] != null) { %>
        <% var user = (FaceSharp.Api.Types.User)ViewData["user"]; %>
        <p>Thank you, <%= user.Name %> for authenticating.</p>
    <% } %>
    The following link is secured through server side authentication:<br />
    <p><%= Html.ActionLink("Secured URL","Index","Test") %> <br />
    (If you attempt to access this link without loggging in and authorizing the app, you should be redirected back here)</p>
    (If you attempt to access this link without loggging in and authorizing the app, you should be redirected back here)</p>

     <hr noshade />
     <h3>Twitter Intents</h3>
     <a href="http://dev.twitter.com/pages/intents">Twitter Documentation - Web Intents</a><br /> <br />
     <div>#Facebook releases the Send button http://ht.ly/4GCxK private messages go social</div>
     <p><a href="http://twitter.com/intent/tweet?in_reply_to=62595594010628096">Reply <img src="http://si0.twimg.com/images/dev/cms/intents/icons/reply_hover.png" /></a></p>
<p><a href="http://twitter.com/intent/retweet?tweet_id=62595594010628096">Retweet <img src="http://si0.twimg.com/images/dev/cms/intents/icons/retweet_hover.png" /></a></p>
<p><a href="http://twitter.com/intent/favorite?tweet_id=62595594010628096">Favorite <img src="http://si0.twimg.com/images/dev/cms/intents/icons/favorite_hover.png" /></a></p>

     <hr noshade />
     <h3>Registration Plugin - IFrame</h3>
     <a href="http://developers.facebook.com/docs/plugins/registration/">Facebook Documentation - Registration Plugin</a>
     <br /> <br />
     <iframe src="http://www.facebook.com/plugins/registration.php?
             client_id=<%= ViewData["ApplicationId"] %>&
             redirect_uri=<% = Server.UrlEncode(HttpContext.Current.Request.Url.AbsoluteUri) %>&
             fields=name,birthday,gender,location,email"
        scrolling="auto"
        frameborder="no"
        style="border:none"
        fb_only="true"
        allowTransparency="true"
        width="100%"
        height="330">
</iframe>
     <br /><br />


     <hr noshade />
     <h3>Registration Plugin - XFBML</h3>
     <a href="http://developers.facebook.com/docs/plugins/registration/">Facebook Documentation - Registration Plugin</a>
     <br /> <br />
     <fb:registration 
  fields="name,birthday,gender,location,email" 
  redirect-uri="<% = HttpContext.Current.Request.Url.AbsoluteUri %>"
  width="530">
</fb:registration>
     <br /><br />


         Share Demos:<br />
    Please <fb:share-button href="<% = HttpContext.Current.Request.Url.AbsoluteUri %>" type="button_count"></fb:share-button>the current page.<br />
    Please <fb:share-button href="http://www.facebook.com/facesharp" type="button_count"></fb:share-button>the FaceSharp Fan page.<br />


     <hr noshade />
     <h3>FB.ui Feed Post</h3>
     <a href="http://developers.facebook.com/docs/reference/javascript/FB.ui">Facebook Documentation - FB.ui</a>
     <br /> <br />
     <input type="button" value="Share with Facebook" onclick="shareIt();"/>
     <br /><br />


     <hr noshade />
     <h3>FB.Login</h3>
     <a href="http://developers.facebook.com/docs/reference/javascript/FB.login/">Facebook Documentation - JavaScript SDK › FB.login</a>
     <br /> <br />
     <input type="button" value="Grant App MORE permissions" onclick="askForMorePermissions();"/>
     <br /><br />


     <hr noshade />
     <h3>FB.api</h3>
     <a href="http://developers.facebook.com/docs/reference/javascript/fb.api/">Facebook Documentation - JavaScript SDK › FB.api</a>
     <br /> <br />
     <input type="button" value="Random CLOSE Friend" onclick="closestFriends();"/>
     <br /><br />
     
     <hr noshade />
     <h3>Tweet Button</h3>
     <a href="http://twitter.com/about/resources/tweetbutton">Twitter Tweet Button Generator</a>
     <p><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-related="FaceSharp" data-url="http://facesharp.codeplex.com" data-text="<% =("Checking out the #FaceSharp open source .NET Facebook starter kit #FacebookDev") %>">Tweet FaceSharp</a></p>
     <script src="http://platform.twitter.com/widgets.js"></script>


     <fb:comments href="<% = HttpContext.Current.Request.Url.AbsoluteUri %>" num_posts="10" width="600"></fb:comments>
     

     
</body>
</html>